
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mymsgro</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/meniu.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />

</h:head>
<h:body>

	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">

		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contenRight">
<f:event type="preRenderView" listener="#{surveyCreateBean.preRenderView}"/>
			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>My Surveys</a></li>
				</ul>
			</h:panelGroup>

			<h:panelGroup layout="block" id="contentTab">
		<h:form>

			<h:body
				rendered="#{surveyListForUserTableData.surveysList.rowCount == 0}">
				<h1>You have not created any surveys!</h1>	
			</h:body>

			<p:dataTable id="surveysTable"
				rendered="#{surveyListForUserTableData.surveysList.rowCount != 0}"
				value="#{surveyListForUserTableData.surveysList}" var="survey"
				paginator="true" rows="5"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">

				<p:column>
					<f:facet name="header">
						<h:commandLink
							action="#{surveyListForUserTableData.surveysList.sortByTitle}">
							<h:outputText value="Title" />
						</h:commandLink>
					</f:facet>
					<h:inputHidden value="#{survey.surveyDTO.id}" />
					<h:outputText value="#{survey.surveyDTO.title}" />
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:commandLink
							action="#{surveyListForUserTableData.surveysList.sortByTitle}">
							<h:outputText value="Description" />
						</h:commandLink>
					</f:facet>
					<h:outputText value="#{survey.surveyDTO.description}"
						 />
						 
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:commandLink
							action="#{surveyListForUserTableData.surveysList.sortByStartDate}">
							<h:outputText value="Start date" />
						</h:commandLink>
					</f:facet>
					<h:outputText value="#{survey.surveyDTO.startDate}">
						<f:convertDateTime type="date" pattern="dd-MM-yyyy" />
					</h:outputText>
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:commandLink
							action="#{surveyListForUserTableData.surveysList.sortByEndDate}">
							<h:outputText value="End date" />
						</h:commandLink>

					</f:facet>
					<h:outputText value="#{survey.surveyDTO.endDate}">
						<f:convertDateTime type="date" pattern="dd-MM-yyyy" />
					</h:outputText>
				</p:column>

				<p:column>
				<f:facet name="header">
						<h:commandLink
							action="#{surveyListForUserTableData.surveysList.sortByTitle}">
							<h:outputText value="Status" />
						</h:commandLink>
					</f:facet>
					<h:outputText value="#{survey.status}" readonly="true" />
					
				</p:column>

				<p:column>
						<h:commandButton style="width: 40px;" image = "resources/img/surveystatistics.png" action="surveyAnswerStats.xhtml">
						

						<f:param name="idSurv" value="#{survey.surveyDTO.id}" />

					</h:commandButton>

				</p:column>

			</p:dataTable>

		</h:form>
	</h:panelGroup>
	</h:panelGroup>
	</h:panelGroup>
</h:body>
</html>